﻿///全选/反选
function CheckAll(e,itemname)
{
    var aa=document.getElementsByName(itemname);
    if(aa==undefined) return;
    for (var i=0; i<aa.length; i++)aa[i].checked = e.checked;
    ShowDelete();
} 
///设置删除按钮是否显示
function ShowDelete()
{
    var rs=false;
    var r=document.getElementsByName("Item"); 
    if(r.length>0)
    {
        for(var i=0;i<r.length;i++)
        {
             if(r[i].checked)
                rs=true;
        }    
        if(!rs)
            document.getElementById("btnDelete").disabled=!document.getElementById("btnDelete").disabled;
        else
            document.getElementById("btnDelete").disabled=false;
    }
}
///全选/反选(订单)
function CheckAllOrder(e,itemname)
{
    var aa=document.getElementsByName(itemname);
    if(aa==undefined) return;
    for (var i=0; i<aa.length; i++)aa[i].checked = e.checked;
    ShowOrderModify();
} 
///设置批量修改按钮是否显示
function ShowOrderModify()
{
    var rs=false;
    var r=document.getElementsByName("Item"); 
    if(r.length>0)
    {
        for(var i=0;i<r.length;i++)
        {
             if(r[i].checked)
                rs=true;
        }    
        if(!rs)
            document.getElementById("btnBulkModify").disabled=!document.getElementById("btnBulkModify").disabled;
        else
            document.getElementById("btnBulkModify").disabled=false;
    }
}
///关键字查询
function keywordSearch(obj)
{
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()==""){
        $("#txtEndDate").select();
        alert("请输入结束日期！");
        return false;
    }
    if($("#txtStartDate").val()==""&&$("#txtEndDate").val()!=""){
        $("#txtStartDate").select();
        alert("请输入开始日期！");
        return false;
    }
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!=""){
        var d1 = new Date(Date.parse($("#txtStartDate").val().replace("-","/")));
        var d2 = new Date(Date.parse($("#txtEndDate").val().replace("-","/")));
        if(d1>d2){
            $("#txtEndDate").select();
            alert("结束日期不能小于开始日期！");
            return false;
        } 
    }
    var so=document.getElementById("selectOrder"); 
    var kw=document.getElementById("txtKeyWord").value;
    var os=document.getElementById("selectOrderStatus"); 
    var ps=document.getElementById("selectPayStatus"); 
    var ds=document.getElementById("selectDeliveryStatus");
    var t = document.getElementById("selectPageSize"); 
    var url=obj+"?ps="+t.options[t.selectedIndex].value;
    url+="&t="+so.options[so.selectedIndex].value+"&kw="+kw;
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!="")
        url+="&sd="+$("#txtStartDate").val()+"&ed="+$("#txtEndDate").val();
    if(os.options[os.selectedIndex].value!="0")
        url+="&"+os.options[os.selectedIndex].value;
    if(ps.options[ps.selectedIndex].value!="0")
        url+="&"+ps.options[ps.selectedIndex].value;
    if(ds.options[ds.selectedIndex].value!="0")
        url+="&"+ds.options[ds.selectedIndex].value;
    location.href=url;
}
///团购订单状态查询
function SetGroupBuyOrderStatus()
{
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()==""){
        $("#txtEndDate").select();
        alert("请输入结束日期！");
        return false;
    }
    if($("#txtStartDate").val()==""&&$("#txtEndDate").val()!=""){
        $("#txtStartDate").select();
        alert("请输入开始日期！");
        return false;
    }
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!=""){
        var d1 = new Date(Date.parse($("#txtStartDate").val().replace("-","/")));
        var d2 = new Date(Date.parse($("#txtEndDate").val().replace("-","/")));
        if(d1>d2){
            $("#txtEndDate").select();
            alert("结束日期不能小于开始日期！");
            return false;
        } 
    }
    var so=document.getElementById("selectOrder"); 
    var kw=document.getElementById("txtKeyWord").value;
    var os=document.getElementById("selectOrderStatus"); 
    var ps=document.getElementById("selectPayStatus"); 
    var ds=document.getElementById("selectDeliveryStatus");
    var t = document.getElementById("selectPageSize"); 
    var url="/backstage/group_buy_order_list.aspx?ps="+t.options[t.selectedIndex].value;  
    url+="&t="+so.options[so.selectedIndex].value+"&kw="+kw;
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!="")
        url+="&sd="+$("#txtStartDate").val()+"&ed="+$("#txtEndDate").val();
    if(os.options[os.selectedIndex].value!="0")
        url+="&"+os.options[os.selectedIndex].value;
    if(ps.options[ps.selectedIndex].value!="0")
        url+="&"+ps.options[ps.selectedIndex].value;
    if(ds.options[ds.selectedIndex].value!="0")
        url+="&"+ds.options[ds.selectedIndex].value;
    location.href=url;
}
///订单状态查询
function SetOrderStatus()
{ 
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()==""){
        $("#txtEndDate").select();
        alert("请输入结束日期！");
        return false;
    }
    if($("#txtStartDate").val()==""&&$("#txtEndDate").val()!=""){
        $("#txtStartDate").select();
        alert("请输入开始日期！");
        return false;
    }
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!=""){
        var d1 = new Date(Date.parse($("#txtStartDate").val().replace("-","/")));
        var d2 = new Date(Date.parse($("#txtEndDate").val().replace("-","/")));
        if(d1>d2){
            $("#txtEndDate").select();
            alert("结束日期不能小于开始日期！");
            return false;
        } 
    }
    var so=document.getElementById("selectOrder"); 
    var kw=document.getElementById("txtKeyWord").value;
    var os=document.getElementById("selectOrderStatus"); 
    var ps=document.getElementById("selectPayStatus"); 
    var ds=document.getElementById("selectDeliveryStatus");
    var t = document.getElementById("selectPageSize"); 
    var url="/backstage/order_list.aspx?ps="+t.options[t.selectedIndex].value;  
    url+="&t="+so.options[so.selectedIndex].value+"&kw="+kw;
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!="")
        url+="&sd="+$("#txtStartDate").val()+"&ed="+$("#txtEndDate").val();
    if(os.options[os.selectedIndex].value!="0")
        url+="&"+os.options[os.selectedIndex].value;
    if(ps.options[ps.selectedIndex].value!="0")
        url+="&"+ps.options[ps.selectedIndex].value;
    if(ds.options[ds.selectedIndex].value!="0")
        url+="&"+ds.options[ds.selectedIndex].value;
    location.href=url;
}
///积分兑换订单状态查询
function SetPointsForOrderStatus()
{
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()==""){
        $("#txtEndDate").select();
        alert("请输入结束日期！");
        return false;
    }
    if($("#txtStartDate").val()==""&&$("#txtEndDate").val()!=""){
        $("#txtStartDate").select();
        alert("请输入开始日期！");
        return false;
    }
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!=""){
        var d1 = new Date(Date.parse($("#txtStartDate").val().replace("-","/")));
        var d2 = new Date(Date.parse($("#txtEndDate").val().replace("-","/")));
        if(d1>d2){
            $("#txtEndDate").select();
            alert("结束日期不能小于开始日期！");
            return false;
        } 
    }
    var so=document.getElementById("selectOrder"); 
    var kw=document.getElementById("txtKeyWord").value;
    var os=document.getElementById("selectOrderStatus"); 
    var ps=document.getElementById("selectPayStatus"); 
    var ds=document.getElementById("selectDeliveryStatus");
    var t = document.getElementById("selectPageSize"); 
    var url="/backstage/points_for_order_list.aspx?ps="+t.options[t.selectedIndex].value;  
    url+="&t="+so.options[so.selectedIndex].value+"&kw="+kw;
    if($("#txtStartDate").val()!=""&&$("#txtEndDate").val()!="")
        url+="&sd="+$("#txtStartDate").val()+"&ed="+$("#txtEndDate").val();
    if(os.options[os.selectedIndex].value!="0")
        url+="&"+os.options[os.selectedIndex].value;
    if(ps.options[ps.selectedIndex].value!="0")
        url+="&"+ps.options[ps.selectedIndex].value;
    if(ds.options[ds.selectedIndex].value!="0")
        url+="&"+ds.options[ds.selectedIndex].value;
    location.href=url;
}
///设置页面显示大小
function SetPageSize()
{
    var t = document.getElementById("selectPageSize"); 
    var q = location.search.substr(1);
    if(q=="")
        location.href=location.href+"?ps="+t.options[t.selectedIndex].value;
    else
    {
        var hf=location.href.split("?")[0]+"?";
        var qs = q.split("&");
        var rs=false;
        for(var i=0;i<qs.length;i++)
        {
            var qsn=qs[i].split("=");
            if(qsn[0]!="ps"&&qsn[0]!="p")
            { 
                if(!rs)
                {   
                    hf+=qs[i];
                    rs=true;
                }
                else
                    hf+="&"+qs[i];
            }
        }
        if(rs)
            hf+="&ps="+t.options[t.selectedIndex].value;
        else
            hf+="ps="+t.options[t.selectedIndex].value;
        location.href=hf;
    }
}
///跳转页面
function GotoPage(pagecount)
{
    var p = document.getElementById("txtGotoPage");
    if(p.value==""){
        alert("请输入跳转页数！");
        return false;
    }
    if(parseInt(p.value)>parseInt(pagecount)){
        alert("您输入的页数不存在！");
        return false;
    }
    var q = location.search.substr(1);
    if(q=="")
        location.href=location.href+"?p="+p.value;
    else
    {
        var hf=location.href.split("?")[0]+"?";
        var qs = q.split("&");
        var rs=false;
        for(var i=0;i<qs.length;i++)
        {
            var qsn=qs[i].split("=");
            if(qsn[0]!="p")
            { 
                if(!rs)
                {   
                    hf+=qs[i];
                    rs=true;
                }
                else
                    hf+="&"+qs[i];
            }
        }
        if(rs)
            hf+="&p="+p.value;
        else
            hf+="p="+p.value;
        location.href=hf;
    }
}
///设置排序字段
function SetOrder(obj)
{ 
    var q = location.search.substr(1);
    if(q=="")
        location.href=location.href+"?or="+obj+"&ot=1";
    else
    {
        var hf=location.href.split("?")[0]+"?";
        var qs = q.split("&");
        var rs=false;
        var ot="1";
        var ots=false;
        for(var i=0;i<qs.length;i++)
        {
            var qsn=qs[i].split("=");
            if(qsn[0]=="or"&&qsn[1]==obj)
                ots=true;
            if(qsn[0]=="ot"&&ots==true)
            {
                if(qsn[1]=="1")
                    ot="0";
                else
                    ot="1";
            }  
            if(qsn[0]!="or"&&qsn[0]!="p"&&qsn[0]!="ot")
            { 
                if(!rs)
                {   
                    hf+=qs[i];
                    rs=true;
                }
                else
                    hf+="&"+qs[i];
            }
        }
        if(rs)
            hf+="&or="+obj+"&ot="+ot;
        else
            hf+="or="+obj+"&ot="+ot;
        location.href=hf;
    }    
}
///设置Select选中项value值
function selectIsExitItem(sId, objItemValue) 
{ 
    var objSelect=document.getElementById(sId);
    for (var i = 0; i < objSelect.options.length; i++) {        
        if (objSelect.options[i].value == objItemValue) {        
            objSelect.options[i].selected = true;    
            break;        
        }        
    }        
}
///设置CheckBox选中项
function selectCheckBox(cbName,chooseValue)
{
    var cv=chooseValue.split(",");
    var cb=document.getElementsByName(cbName);
    for(var i=0;i<cb.length;i++)
    {
        var rs=false;
        for(var j=0;j<cv.length;j++)
        {
            if(cv[j]==cb[i].value)
            {
                rs=true;
                break;
            } 
        }
        if(rs)
            cb[i].checked="checked";
    }
}
///添加表单选项
function AddAttributeValues()
{
    var tb = document.getElementById("AttributeValues");
    newRow = tb.insertRow(tb.rows.length);
    newRow.width="100%";
    newCell2=newRow.insertCell(-1);
    newCell2.innerHTML="选项内容：<input name=\"attributeValue\" type=\"text\"/><input type=button class=\"formButton\" value=\"删除\" title=\"删除选项\" onclick=\"delInput(this.parentNode.parentNode.rowIndex);\">";
}
///删除表单选项
function delInput(index)
{
    if(confirm("确定要删除吗？"))
    {
        var tb = document.getElementById("AttributeValues");
        document.getElementById("AttributeValues").deleteRow(index);
    }
}
function displayAttributeValues(choose)
{
    if(choose.options[choose.selectedIndex].value=="3"||choose.options[choose.selectedIndex].value=="4")
        document.getElementById("AttributeValues").style.display="block";
    else
        document.getElementById("AttributeValues").style.display="none";
}
///验证商品类型属性表单
function checkAttributesForm()
{
    var goodsType=document.getElementById("selectGoodsType");
    if(goodsType.options[goodsType.selectedIndex].value=="0")
    {
        alert("请选择商品类型！");
        return false;
    }
    var attributeName=document.getElementById("txtAttributeName");
    if(attributeName.value=="")
    {
        alert("请输入属性名称！");
        attributeName.focus();
        return false;
    }
    var attributeInputType=document.getElementById("selectAttributeInputType");
    if(attributeInputType.options[attributeInputType.selectedIndex].value=="-1")
    {
        alert("请选择属性类型！");
        return false;
    }
    if(attributeInputType.options[attributeInputType.selectedIndex].value=="3"||attributeInputType.options[attributeInputType.selectedIndex].value=="4")
    {
        var attributeValue=document.getElementsByName("attributeValue");
        for(var i=0;i<attributeValue.length;i++)
        {
            if(attributeValue[i].value=="")
            {
                alert("请输入选项内容！");
                attributeValue[i].focus();
                return false;
            }
        }
    }
    var sortOrder=document.getElementById("txtSortOrder");
    if(sortOrder.value=="")
    {
        alert("请输入排序！");
        sortOrder.focus();
        return false;
    }
    return true;    
} 
function secBoard(n)
{
    document.getElementById("td2").className="sec2";
    for(i=1;i<5;i++)
    {
        document.getElementById("tab"+i+"").style.display="none";
        document.getElementById("td"+i+"").className="sec1";
    }
    document.getElementById("tab"+n+"").style.display="block";
    document.getElementById("td"+n+"").className="sec2";
}

function secBoardBatch(n)
{
    document.getElementById("td2").className="sec2";
    for(i=1;i<4;i++)
    {
        document.getElementById("tab"+i+"").style.display="none";
        document.getElementById("td"+i+"").className="sec1";
    }
    document.getElementById("tab"+n+"").style.display="block";
    document.getElementById("td"+n+"").className="sec2";
}

function secAd(n)
{
    document.getElementById("td2").className="sec2";
    for(i=1;i<6;i++)
    {
        document.getElementById("tab"+i+"").style.display="none";
        document.getElementById("td"+i+"").className="sec1";
    }
    document.getElementById("tab"+n+"").style.display="block";
    document.getElementById("td"+n+"").className="sec2";
}


///添加商品规格
function getSpecifications(id,obj)
{
    var sId=id*1.0;
    var a=Gift.WebApp.Goods_ajax.GetSpecificationsById(sId).value;
    document.getElementById("Specifications").innerHTML=a;
    var ss=document.getElementsByName("ss");
    var tb=document.getElementById("GoodsEntitysSpecifications");
    for(var i=0;i<ss.length;i++)
    {
        if(ss[i].checked)
        {
            var sId="spanS"+ss[i].value;
            var sName=Gift.WebApp.Goods_ajax.GetSpecificationsNameById(ss[i].value).value;
            var sValueName=Gift.WebApp.Goods_ajax.GetSpecificationsValueNameById(ss[i].value).value;
            if(!document.getElementById(sId))
            {
                for(var j=0;j<tb.rows.length;j++)
                {
                    if(j==0)
                    {
                        var cell=tb.rows[j].insertCell(2);
                        cell.innerHTML="<span id=\""+sId+"\">"+sName+"</span>";
                    }
                    else
                    {
                        var cell=tb.rows[j].insertCell(2);
                        cell.innerHTML=sValueName;
                    }
                }
            }
        }
        else
        {
            var sId="spanS"+ss[i].value;
            if(document.getElementById(sId))
            {
                var tdId=document.getElementById(sId).parentNode.cellIndex;
                for(var j=0;j<tb.rows.length;j++)
                {
                    if(j==0)
                        tb.rows[j].deleteCell(tdId);
                    else
                        tb.rows[j].deleteCell(tdId);
                }
            }
        }
    }
}

///添加商品规格(批量添加)
function getSpecificationsBatch(id,obj)
{
    var sId=id*1.0;
    var a=Gift.WebApp.Goods_ajax.GetSpecificationsById(sId).value;
    document.getElementById("Specifications").innerHTML=a;
    var ss=document.getElementsByName("ss");
    var tb=document.getElementById("GoodsEntitysSpecifications");
    for(var i=0;i<ss.length;i++)
    {
        if(ss[i].checked)
        {
            var sId="spanS"+ss[i].value;
            var sName=Gift.WebApp.Goods_ajax.GetSpecificationsNameById(ss[i].value).value;
            var sValueName=Gift.WebApp.Goods_ajax.GetSpecificationsValueNameById(ss[i].value).value;
            if(!document.getElementById(sId))
            {
                for(var j=0;j<tb.rows.length;j++)
                {
                    if(j==0)
                    {
                        var cell=tb.rows[j].insertCell(0);
                        cell.innerHTML="<span id=\""+sId+"\">"+sName+"</span>";
                    }
                    else
                    {
                        var cell=tb.rows[j].insertCell(0);
                        cell.innerHTML=sValueName;
                    }
                }
            }
        }
        else
        {
            var sId="spanS"+ss[i].value;
            if(document.getElementById(sId))
            {
                var tdId=document.getElementById(sId).parentNode.cellIndex;
                for(var j=0;j<tb.rows.length;j++)
                {
                    if(j==0)
                        tb.rows[j].deleteCell(tdId);
                    else
                        tb.rows[j].deleteCell(tdId);
                }
            }
        }
    }
}
///获取商品类型属性信息
function getAttributes()
{
    var gt=(document.getElementById("SelectGoodsType").value)*1.0;
    if(gt!=0)
    {
        var a=Gift.WebApp.Goods_ajax.GetAtrributesForm(gt,1).value;
        document.getElementById("goodsType").innerHTML=a;
    }
    else
        document.getElementById("goodsType").innerHTML="";
}
///添加商品销售规格表单
function AddGoodsEntitys()
{
    var tb=document.getElementById("GoodsEntitysSpecifications");
    newRow = tb.insertRow(tb.rows.length);
    newRow.width="100%";
    
    newCell0=newRow.insertCell(0);
    newCell0.innerHTML="<input name=\"barCode\" type=\"text\" class=\"specifications\" />";
    
    newCell1=newRow.insertCell(1);
    newCell1.innerHTML="<input name=\"hdGoodsEntitys\" type=\"hidden\" value=\"0\" /><input name=\"goodsArtno\" type=\"text\" class=\"specifications\" value=\"\" />";
    
    var ss=document.getElementsByName("ss");
    var sp=2;
    for(var i=0;i<ss.length;i++)
    {
        if(ss[i].checked)
        {
            newCell=newRow.insertCell(sp);
            newCell.innerHTML=tb.rows[1].cells[sp].innerHTML;
            sp++;
        }
    }
    newCell2=newRow.insertCell(sp*1.0);
    newCell2.innerHTML="<input name=\"salePrice\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell3=newRow.insertCell(sp*1.0);
    newCell3.innerHTML="<input name=\"costPrice\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell4=newRow.insertCell(sp*1.0);
    newCell4.innerHTML="<input name=\"marketPrice\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell5=newRow.insertCell(sp*1.0);
    newCell5.innerHTML="<input name=\"giveIntegral\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell6=newRow.insertCell(sp*1.0);
    newCell6.innerHTML="<input name=\"goodsWeight\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell7=newRow.insertCell(sp*1.0);
    newCell7.innerHTML="<select name=\"selectWeightUnit\"><option value=\"克\">克 </option><option value=\"千克\">千克 </option><option value=\"吨\">吨 </option></select>";
    sp++;
    newCell8=newRow.insertCell(sp*1.0);
    newCell8.innerHTML="<input name=\"inventory\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell9=newRow.insertCell(sp*1.0);
    newCell9.innerHTML="<input type=\"button\" class=\"formButton\" value=\"删除\" title=\"删除货品\" onclick=\"delGoodsEntitys(this.parentNode.parentNode.rowIndex,'0');\">";
}

///添加商品销售规格表单(批量)
function BatchAddGoodsEntitys()
{
    var tb=document.getElementById("GoodsEntitysSpecifications");
    newRow = tb.insertRow(tb.rows.length);
    newRow.width="100%";
    
    var ss=document.getElementsByName("ss");
    var sp=0;
    for(var i=0;i<ss.length;i++)
    {
        if(ss[i].checked)
        {
            newCell=newRow.insertCell(sp);
            newCell.innerHTML=tb.rows[1].cells[sp].innerHTML;
            sp++;
        }
    }
    newCell0=newRow.insertCell(sp*1.0);
    newCell0.innerHTML="<input name=\"salePrice\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell1=newRow.insertCell(sp*1.0);
    newCell1.innerHTML="<input name=\"costPrice\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell2=newRow.insertCell(sp*1.0);
    newCell2.innerHTML="<input name=\"marketPrice\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell3=newRow.insertCell(sp*1.0);
    newCell3.innerHTML="<input name=\"giveIntegral\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell4=newRow.insertCell(sp*1.0);
    newCell4.innerHTML="<input name=\"goodsWeight\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell5=newRow.insertCell(sp*1.0);
    newCell5.innerHTML="<select name=\"selectWeightUnit\"><option value=\"克\">克 </option><option value=\"千克\">千克 </option><option value=\"吨\">吨 </option></select>";
    sp++;
    newCell6=newRow.insertCell(sp*1.0);
    newCell6.innerHTML="<input name=\"inventory\" type=\"text\" class=\"specifications\" value=\"0\" />";
    sp++;
    newCell7=newRow.insertCell(sp*1.0);
    newCell7.innerHTML="<input type=\"button\" class=\"formButton\" value=\"删除\" title=\"删除货品\" onclick=\"delGoodsEntitys(this.parentNode.parentNode.rowIndex,'0');\">";
}
///删除商品销售规格表单
function delGoodsEntitys(index,id)
{
    if(id!=0)
    {
        if(confirm("商品销售规格删除将无法恢复，确定要删除吗？"))
        {
            var result=Gift.WebApp.Goods_ajax.DeleteGoodsEntitysById(id).value;
            if(result)
            {
                var tb = document.getElementById("GoodsEntitysSpecifications");
                document.getElementById("GoodsEntitysSpecifications").deleteRow(index);
            }
        }
    }
    else
    {
        if(confirm("确定要删除吗？"))
        {
            var tb = document.getElementById("GoodsEntitysSpecifications");
            document.getElementById("GoodsEntitysSpecifications").deleteRow(index);
        }
    }    
}
///添加商品图片表单选项
function AddGoodGallerys()
{
    var tb = document.getElementById("GoodGallerys");
    newRow = tb.insertRow(tb.rows.length);
    newRow.width="100%";
    newCell0=newRow.insertCell(0);
    newCell0.innerHTML="<input name=\"hdGoodGallery\" type=\"hidden\" value=\"0\" /><input name=\"fileGoodGallery\" type=\"file\" /><span class=\"imgClass\"> *分辨率大于500*500的等比例图片</span>";
    newCell1=newRow.insertCell(1);
    newCell1.innerHTML="<input name=\"imgAlt\" type=\"text\" />";
    newCell2=newRow.insertCell(2);
    newCell2.innerHTML="<input type=\"button\" class=\"formButton\" value=\"删除\" title=\"删除图片\" onclick=\"delGalleryInput(this.parentNode.parentNode.rowIndex,0);\" />";
}
///删除商品图片表单选项
function delGalleryInput(index,id)
{
    var tb = document.getElementById("GoodGallerys");
    if(tb.rows.length==2)
        return;
    if(id*1.0==0)
    {
        if(confirm("确定要删除吗？"))
        {
            document.getElementById("GoodGallerys").deleteRow(index);
        }
    }
    else
    {
        if(confirm("图片删除后将无法恢复，确定要删除吗？"))
        {
            var result=Gift.WebApp.Goods_ajax.DeleteGoodGalleryById(id).value;
            if(result)
                document.getElementById("GoodGallerys").deleteRow(index);
        }
    }
}
///验证商品表单
function checkGoodsForm()
{
    var goodsName=document.getElementById("txtGoodsName");
    if(goodsName.value=="")
    {
        alert("请输入商品名称！");
        secBoard(1);
        goodsName.focus();
        return false;
    }
    var goodsNo=document.getElementById("txtGoodsNo");
    if(goodsNo.value=="")
    {
        alert("请输入商品编号！");
        secBoard(1);
        goodsNo.focus();
        return false;
    }
    var creategory=document.getElementById("selectAddCategory");
    if(creategory.options.length==0)
    {
        alert("请至少选择一个商品分类！");
        secBoard(1);
        document.getElementById("selectAddCategory").focus();
        return false;
    }
    for(var z=0;z<creategory.options.length;z++)
    {
        creategory.options[z].selected=true;
    }
    var brand=document.getElementById("selectBrand");
    if(brand.options[brand.selectedIndex].value=="0")
    {
        alert("请选择商品品牌！");
        secBoard(1);
        brand.focus();
        return false;
    }
    var item = $("input[name='isFromFreight']:checked").val();
    if(item=="0")
    {
        if($("#selectFreightTemplate").val()=="0")
        {
            $("#selectFreightTemplate").select();
            alert("请选择运费模版！");
            return false;
        }
    }
    var fileGoodGallery=document.getElementsByName("fileGoodGallery");
    var hdGoodGallery=document.getElementsByName("hdGoodGallery");
    for(var x=0;x<fileGoodGallery.length;x++)
    {
        if(fileGoodGallery[x].value==""&&hdGoodGallery[x].value=="0")
        {
            alert("请选择展示图片！");
            secBoard(2);
            fileGoodGallery[x].focus();
            return false;
        }
        if(fileGoodGallery[x].value != "")
        {
            //检测类型
            var val = fileGoodGallery[x].value.toLowerCase();
            if(/^.*?\.(gif|png|jpg|jpeg|bmp)$/.test(val)){
            }else{
                alert("展示图片只能上传gif, png, jpg, bmp格式的图片");
                fileGoodGallery[x].select();
                return false;
            }
        }
    }
    var geId=document.getElementsByName("hdGoodsEntitys");
    ///验证条形码
    var barCode=document.getElementsByName("barCode");
    for(var n=0;n<barCode.length;n++)
    {
        if(barCode(n).value=="")
        {
            alert("请输入条形码！");
            secBoard(3);
            barCode(n).focus();
            return false;
        }
        if(Gift.WebApp.Goods_ajax.CheckBarCode(barCode(n).value,geId(n).value).value)
        {
            alert("条形码已存在，请重新输入！");
            secBoard(3);
            barCode(n).select();
            return false;
        }
        if(barCode.length>1)
        {
            for(var a=n+1;a<barCode.length;a++)
            {
                if(barCode(n).value==barCode(a).value)
                {
                    alert("条形码已存在，请重新输入！");
                    secBoard(3);
                    barCode(a).select();
                    return false;
                }
            }
        }
    }

    ///验证商品货号
    var goodsArtno=document.getElementsByName("goodsArtno");
    for(var n=0;n<goodsArtno.length;n++)
    {
        if(goodsArtno(n).value=="")
        {
            alert("请输入商品货号！");
            secBoard(3);
            goodsArtno(n).focus();
            return false;
        }
        if(Gift.WebApp.Goods_ajax.CheckGoodsArtno(goodsArtno(n).value,geId(n).value).value)
        {
            alert("商品货号已存在，请重新输入！");
            secBoard(3);
            goodsArtno(n).select();
            return false;
        }
        if(goodsArtno.length>1)
        {
            for(var a=n+1;a<goodsArtno.length;a++)
            {
                if(goodsArtno(n).value==goodsArtno(a).value)
                {
                    alert("商品货号已存在，请重新输入！");
                    secBoard(3);
                    goodsArtno(a).select();
                    return false;
                }
            }
        }
    }
    ///验证销售价格
    var salePrice=document.getElementsByName("salePrice");
    for(var sp=0;sp<salePrice.length;sp++)
    {
        if(salePrice(sp).value=="")
        {
            alert("请输入销售价！");
            secBoard(3);
            salePrice(sp).focus();
            return false;
        }
    }
    //验证成本价格
    var costPrice=document.getElementsByName("costPrice");
    for(var cp=0;cp<costPrice.length;cp++)
    {
        if(costPrice(cp).value=="")
        {
            alert("请输入成本价！");
            secBoard(3);
            costPrice(cp).focus();
            return false;
        }
    }
    
    //验证市场价格
    var marketPrice=document.getElementsByName("marketPrice");
    for(var mp=0;mp<marketPrice.length;mp++)
    {
        if(marketPrice(mp).value=="")
        {
            alert("请输入市场价！");
            secBoard(3);
            marketPrice(mp).focus();
            return false;
        }
    }
//    //验证促销价格,促销开始日期,促销结束日期
//    var promotionPrice=document.getElementsByName("promotionPrice");
//    var promotionStartDate=document.getElementsByName("promotionStartDate");
//    var promotionEndDate=document.getElementsByName("promotionEndDate");
//    
//    var tb=document.getElementById("GoodsEntitysSpecifications");
//    
//    for(var tip=0;tip<(tb.rows.length-1);tip++)
//    {
//        var ipId="isPromote"+tip;
//        var isPromote=document.getElementsByName(ipId);
//        if(isPromote[0].checked)
//        {
//            var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
//            if(promotionPrice[tip].value=="")
//            {
//                alert("请输入促销价！");
//                secBoard(3);
//                promotionPrice[tip].focus();
//                return false;
//            }
//            if(promotionStartDate[tip].value=="")
//            {
//                alert("请输入促销开始日期！");
//                secBoard(3);
//                promotionStartDate[tip].focus();
//                return false;
//            }
//            else if(promotionStartDate[tip].value.match(reg)==null)
//            {
//                alert("促销开始日期格式不正确！");
//                secBoard(3);
//                promotionStartDate[tip].select();
//                return false;
//            }
//            if(promotionEndDate[tip].value=="")
//            {
//                alert("请输入促销结束日期！");
//                secBoard(3);
//                promotionEndDate[tip].focus();
//                return false;
//            }
//            else if(promotionEndDate[tip].value.match(reg)==null)
//            {
//                alert("促销结束日期格式不正确！");
//                secBoard(3);
//                promotionEndDate[tip].select();
//                return false;
//            }
//            var d1=new Date(promotionStartDate[tip].value.replace(/\-/g,"/"));
//            var d2=new Date(promotionEndDate[tip].value.replace(/\-/g,"/"));
//            if(d1>d2)
//            {
//                alert("促销开始日期不能大于结束日期！");
//                secBoard(3);
//                promotionEndDate[tip].select();
//                return false;
//            }
//        }
//    }
    //验证兑换积分
    
    if($("input[name='isIntegral']:checked").val()=="1"){
        var it=$("input[name='giveIntegral']");
        for(var ii=0;ii<it.length;ii++){
            if(it[ii].value==""){
                alert("请输入兑换积分！");
                secBoard(3);
                it[ii].focus();
                return false;
            }
        }
    }
    //验证赠送积分
    var giveIntegral=document.getElementsByName("giveIntegral");
    for(var gii=0;gii<giveIntegral.length;gii++)
    {
        if(giveIntegral[gii].value=="")
        {
            alert("请输入赠送积分！");
            secBoard(3);
            giveIntegral[gii].focus();
            return false;
        }
    }
    //验证重量
    var goodsWeight=document.getElementsByName("goodsWeight");
    for(var gwi=0;gwi<goodsWeight.length;gwi++)
    {
        if(goodsWeight[gwi].value=="")
        {
            alert("请输入重量！");
            secBoard(3);
            goodsWeight[gwi].focus();
            return false;
        }
    }
    //验证库存
    var inventory=document.getElementsByName("inventory");
    for(var iti=0;iti<inventory.length;iti++)
    {
        if(inventory[iti].value=="")
        {
            alert("请输入库存！");
            secBoard(3);
            inventory[iti].focus();
            return false;
        }
    }
    var goodsType=document.getElementById("SelectGoodsType");
    if(goodsType.options[goodsType.selectedIndex].value=="0")
    {
        alert("请选择商品类型！");
        secBoard(4);
        goodsType.focus();
        return false;
    }
    ///txtbox必填表单验证
    var atrributesValue=document.getElementsByName("atrributesValue");
    var hdAtrributesValue=document.getElementsByName("hdAtrributesValue");
    for(var i=0;i<atrributesValue.length;i++)
    {
        if(hdAtrributesValue[i].value=="1")
            if(atrributesValue[i].value=="")
            {
                alert("请输入"+atrributesValue[i].title+"！");
                secBoard(4);
                atrributesValue[i].focus();
                return false;
            }
    }
    ///radio和check必选表单验证
    var hdAtrributes=document.getElementsByName("hdAtrributes");
    for(var j=0;j<hdAtrributes.length;j++)
    {
        var atrributes=document.getElementsByName(hdAtrributes[j].value);
        var rs=false;
        for(var z=0;z<atrributes.length;z++)
        {
            if(atrributes[z].checked)
            {
                rs=true;
                break;
            }
        }
        if(!rs)
        {
            alert("请选择"+hdAtrributes[j].title+"！");
            secBoard(4);
            atrributes[0].focus();
            return false;
        }
    }
    
    return true;
}
///验证招聘职位表单
function checkRecruitmentForm()
{
    var jobTitle=document.getElementById("txtJobTitle");
    if(jobTitle.value=="")
    {
        alert("请输入职位名称！");
        jobTitle.focus();
        return false;
    }
    var workAddress=document.getElementById("txtWorkAddress");
    if(workAddress.value=="")
    {
        alert("请输入工作地点！");
        workAddress.focus();
        return false;
    }
    var recruitmentCount=document.getElementById("txtRecruitmentCount");
    if(recruitmentCount.value=="")
    {
        alert("请输入招聘人数！");
        recruitmentCount.focus();
        return false;
    }
    var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
    var startDate=document.getElementById("txtStartDate");
    if(startDate.value=="")
    {
        alert("请输入开始日期！");
        startDate.focus();
        return false;
    }
    else if(startDate.value.match(reg)==null)
    {
        alert("开始日期格式不正确！");
        startDate.select();
        return false;
    }
    var endDate=document.getElementById("txtEndDate");
    if(endDate.value=="")
    {
        alert("请输入结束日期！");
        endDate.focus();
        return false;
    }
    else if(endDate.value.match(reg)==null)
    {
        alert("结束日期格式不正确！");
        endDate.select();
        return false;
    }
    var d1=new Date(startDate.value.replace(/\-/g,"/"));
    var d2=new Date(endDate.value.replace(/\-/g,"/"));
    if(d1>d2)
    {
        alert("开始日期不能大于结束日期！");
        endDate.select();
        return false;
    }
    var fckSkill=FCKeditorAPI.GetInstance("fckSkill"); 
    if(fckSkill.GetXHTML()=="")
    {
        alert("请输入技能要求！");
        fckSkill.Focus();
        return false;
    }
    else
    {
        if(fckSkill.GetXHTML().length>4000)
        {
            alert("技能要求最多不能超过4000个字符！");
            fckSkill.Focus();
            return false;
        }
    }
    return true;
}

///验证会员等级表单
function checkUserRankForm()
{
    var rankName=document.getElementById("txtRankName");
    if(rankName.value=="")
    {
        alert("请输入等级名称！");
        rankName.focus();
        return false;
    }
    var re = /^[\d]+$/;
    var points=document.getElementById("txtPoints");
    if(points.value=="")
    {
        alert("请输入所需积分！");
        points.focus();
        return false;
    }
    else if(points.value.match(re)==null)
    {
        alert("积分只能输入数字！");
        points.select();
        return false;
    }
    var discount=document.getElementById("txtDiscount");
    if(discount.value=="")
    {
        alert("请输入优惠百分比！");
        discount.focus();
        return false;
    }
    if(discount.value.match(re)==null)
    {
        alert("优惠百分比只能输入数字！");
        discount.select();
        return false;
    }
}
///验证会员表单
function checkUserForm()
{
    var userName=document.getElementById("txtUserName");
    if(userName.value=="")
    {
        alert("请输入用户名！");
        userName.focus();
        return false;
    }
    var userPwd=document.getElementById("txtUserPwd");
    var againPwd=document.getElementById("txtAgainPwd");
    if(location.search=="?ot=ad")
    {
        if(userPwd.value=="")
        {
            alert("请输入密码！");
            userPwd.focus();
            return false;
        }
        if(againPwd.value=="")
        {
            alert("请输入确认密码！");
            againPwd.focus();
            return false;
        }
        if(againPwd.value!=userPwd.value)
        {
            alert("确认密码不一致！");
            againPwd.select();
            return false;
        }
    }
    else
    {
         if(userPwd.value!="")
         {
            if(againPwd.value=="")
            {
                alert("请输入确认密码！");
                againPwd.focus();
                return false;
            }
            if(againPwd.value!=userPwd.value)
            {
                alert("确认密码不一致！");
                againPwd.select();
                return false;
            }
         }
    }
    var regu =/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    var email=document.getElementById("txtEmail");
    if(email.value=="")
    {
        alert("请输入E_Mail！");
        email.focus();
        return false;
    }
    else if(email.value.match(regu)==null)
    {
        alert("请输入正确的E_Mail！");
        email.select();
        return false;
    }
    var re = /^[\d]+$/;
    var payPoints=document.getElementById("txtPayPoints");
    if(payPoints.value=="")
    {
        alert("请输入积分！");
        payPoints.focus();
        return false;
    }
    else if(payPoints.value.match(re)==null)
    {
        alert("积分只能输入数字！");
        payPoints.select();
        return false;
    }
    var money=document.getElementById("txtMoney");
    if(money.value=="")
    {
        alert("请输入预存款！");
        money.focus();
        return false;
    }
    var userRank=document.getElementById("selectUserRank");
    if(userRank.options[userRank.selectedIndex].value=="0")
    {
        alert("请选择会员等级！");
        userRank.focus();
        return false;
    }
    return true;
}
///验证发送消息表单
function checkSendMessageForm()
{
    var addressee=document.getElementById("txtAddressee");
    if(addressee.value=="")
    {
        alert("请输入收件人！");
        addressee.focus();
        return false;
    }
    else
    {
        var rs=BLL.UserManager.DetectionUser(addressee.value).value;
        if(rs)
        {
            alert("用户名不存在，请重新输入！");
            addressee.select();
            return false;
        }
    }
    var title=document.getElementById("txtTitle");
    if(title.value=="")
    {
        alert("请输入标题！");
        title.focus();
        return false;
    }
    var content=document.getElementById("txtaContent");
    if(content.value=="")
    {
        alert("请输入内容！");
        content.focus();
        return false;
    }
    else
    {
        if(content.value.length>4000)
        {
            alert("内容最多不能超过4000个字符！");
            content.select();
            return false;
        }
    }
    return true;
}
///验证在线留言回复表单
function checkMessageReplyForm()
{
    var replyTitle=document.getElementById("txtReplyTitle");
    if(replyTitle.value=="")
    {
        alert("请输入回复标题！");
        replyTitle.focus();
        return false;
    }
    var replyContent=document.getElementById("txtaReplyContent");
    if(replyContent.value=="")
    {
        alert("请输入回复内容！");
        replyContent.focus();
        return false;
    }
    else
    {
        if(replyContent.value.length>500)
        {
            alert("回复内容最多不能超过500个字符！");
            replyContent.select();
            return false;
        }
    }
    return true;
}
///验证地区表单
function checkRegionForm()
{
    var regionName=document.getElementById("txtRegionName");
    if(regionName.value=="")
    {
        alert("请输入地区名称！");
        regionName.focus();
        return false;
    }
    return true;
}
///验证网站邮件服务表单
function checkMailForm()
{
    var regu =/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    var fromAddress=document.getElementById("txtFromAddress");
    if(fromAddress.value=="")
    {
        alert("请输入发件人邮箱地址！");
        fromAddress.focus();
        return false;
    }
    else
    {
        if(fromAddress.value.match(regu)==null)
        {
            alert("请输入正确的发件人邮箱地址！");
            fromAddress.select();
            return false;
        }
    }
    var fromName=document.getElementById("txtFromName");
    if(fromName.value=="")
    {
        alert("请输入发件人姓名！");
        fromName.focus();
        return false;
    }
    var mailDomain=document.getElementById("txtMailDomain");
    if(mailDomain.value=="")
    {
        alert("请输入SMTP服务器地址！");
        mailDomain.focus();
        return false;
    }
    var mailDomainPort=document.getElementById("txtMailDomainPort");
    if(mailDomainPort.value=="")
    {
        alert("请输入SMTP服务器端口号！");
        mailDomainPort.focus();
        return false;
    }
    var mailServerUserName=document.getElementById("txtMailServerUserName");
    if(mailServerUserName.value=="")
    {
        alert("请输入SMTP用户名！");
        mailServerUserName.focus();
        return false;
    }
    else
    {
        if(mailServerUserName.value.match(regu)==null)
        {
            alert("请输入正确的SMTP用户名！");
            mailServerUserName.select();
            return false;
        }
    }
    var mailServerPassWord=document.getElementById("txtMailServerPassWord");
    if(mailServerPassWord.value=="")
    {
        alert("请输入SMTP密码！");
        mailServerPassWord.focus();
        return false;
    }
    return true;
}
///验证发送邮件测试表单
function sendMail()
{
    var regu =/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    var fromAddress=document.getElementById("txtFromAddress");
    if(fromAddress.value=="")
    {
        alert("请输入发件人邮箱地址！");
        fromAddress.focus();
        return false;
    }
    else
    {
        if(fromAddress.value.match(regu)==null)
        {
            alert("请输入正确的发件人邮箱地址！");
            fromAddress.select();
            return false;
        }
    }
    var fromName=document.getElementById("txtFromName");
    if(fromName.value=="")
    {
        alert("请输入发件人姓名！");
        fromName.focus();
        return false;
    }
    var mailDomain=document.getElementById("txtMailDomain");
    if(mailDomain.value=="")
    {
        alert("请输入SMTP服务器地址！");
        mailDomain.focus();
        return false;
    }
    var mailDomainPort=document.getElementById("txtMailDomainPort");
    if(mailDomainPort.value=="")
    {
        alert("请输入SMTP服务器端口号！");
        mailDomainPort.focus();
        return false;
    }
    var mailServerUserName=document.getElementById("txtMailServerUserName");
    if(mailServerUserName.value=="")
    {
        alert("请输入SMTP用户名！");
        mailServerUserName.focus();
        return false;
    }
    else
    {
        if(mailServerUserName.value.match(regu)==null)
        {
            alert("请输入正确的SMTP用户名！");
            mailServerUserName.select();
            return false;
        }
    }
    var mailServerPassWord=document.getElementById("txtMailServerPassWord");
    if(mailServerPassWord.value=="")
    {
        alert("请输入SMTP密码！");
        mailServerPassWord.focus();
        return false;
    }
    var mailTo=document.getElementById("txtMailTo");
    if(mailTo.value=="")
    {
        alert("请输入收件人邮箱！");
        mailTo.focus();
        return false;
    }
    else
    {
        if(mailTo.value.match(regu)==null)
        {
            alert("请输入正确的收件人邮箱！");
            mailTo.select();
            return false;
        }
    }
    return true;
}
///验证物流公司表单
function checkLogisticsCompanyForm()
{
    var logisticsCompanyName=document.getElementById("txtLogisticsCompanyName");
    if(logisticsCompanyName.value=="")
    {
        alert("请输入物流公司名称！");
        logisticsCompanyName.focus();
        return false;
    }
    var logisticsCompanyUrl=document.getElementById("txtLogisticsCompanyUrl");
    var regUrl=/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]':+!]*([^<>\"\"])*$/;
    if(logisticsCompanyUrl.value=="")
    {
        alert("请输入物流公司网址！");
        logisticsCompanyUrl.focus();
        return false;
    }
    else
    {
        if(logisticsCompanyUrl.value.match(regUrl)==null)
        {
            alert("请输入正确的物流公司网址！");
            logisticsCompanyUrl.select();
            return false;
        }
    }
    var sortOrder=document.getElementById("txtSortOrder");
    if(sortOrder.value=="")
    {
        alert("请输入排序！");
        sortOrder.focus();
        return false;
    }
    return true;
}
///验证商品类型表单
function checkGoodsTypeForm()
{
    var typeName=document.getElementById("txtTypeName");
    if(typeName.value=="")
    {
        alert("请输入商品类型名称！");
        typeName.focus();
        return false;
    }
    return true;
}
///验证友情链接表单
function checkFrendLinkForm()
{
    var linkName=document.getElementById("txtLinkName");
    if(linkName.value=="")
    {
        alert("请输入友情链接名称！");
        linkName.focus();
        return false;
    }
    var regUrl=/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]':+!]*([^<>\"\"])*$/;
    var linkUrl=document.getElementById("txtLinkUrl");
    if(linkUrl.value=="")
    {
        alert("请输入链接地址！");
        linkUrl.focus();
        return false;
    }
    else
    {
        if(linkUrl.value.match(regUrl)==null)
        {
            alert("请输入正确的链接地址！");
            linkUrl.select();
            return false;
        }
    }
    var linkLogo=document.getElementById("fileLinkLogo");
    if(location.search=="?ot=ad")
    {
        if(linkLogo.value=="")
        {
            alert("请选择LOGO！");
            linkLogo.focus();
            return false;
        }
        if(linkLogo.value != "")
        {
            //检测类型
            var val = linkLogo.value.toLowerCase();
            if(/^.*?\.(gif|png|jpg|jpeg|bmp)$/.test(val)){
            }else{
                alert("LOGO只能上传gif, png, jpg, bmp格式的图片");
                linkLogo.select();
                return false;
            }
        }
    }
    else
    {
        if(linkLogo.value != "")
        {
            //检测类型
            var val = linkLogo.value;
            if(/^.*?\.(gif|png|jpg|jpeg|bmp)$/.test(val)){
            }else{
                alert("LOGO只能上传gif, png, jpg, bmp格式的图片");
                linkLogo.select();
                return false;
            }
        }
    }
    var sortOrder=document.getElementById("txtSortOrder");
    if(sortOrder.value=="")
    {
        alert("请输入排序！");
        sortOrder.focus();
        return false;
    }
    return true;
}
///验证商品分类表单
function checkCategoryForm()
{
    var categoryName=document.getElementById("txtCategoryName");
    if(categoryName.value=="")
    {
        alert("请输入分类名称！");
        categoryName.focus();
        return false;
    }
    var sortOrder=document.getElementById("txtSortOrder");
    if(sortOrder.value=="")
    {
        alert("请输入排序！");
        sortOrder.focus();
        return false;
    }
    var brand=document.getElementsByName("brand");
    var rs=false;
    for(var i=0;i<brand.length;i++)
    {
        if(brand[i].checked)
            rs=true;
    }
    if(!rs)
    {
        alert("请至少选择一个关联品牌！");
        brand[0].focus();
        return false;
    }
    var keywords=document.getElementById("txtKeywords");
    if(keywords.value=="")
    {
        alert("请输入页面关键词！");
        keywords.focus();
        return false;
    }
    var description=document.getElementById("txtaDescription");
    if(description.value=="")
    {
        alert("请输入页面描述！");
        description.focus();
        return false;
    }
    else
    {
        if(description.value.length>200)
        {
            alert("页面描述最多不能超过200个字符！");
            description.select();
            return false;
        }
    }
    var categoryAd=document.getElementsByName("categoryAd");
    for(var x=0;x<categoryAd.length;x++)
    {
        if(categoryAd[x].value != "")
        {
            //检测类型
            var val = categoryAd[x].value.toLowerCase();
            if(/^.*?\.(jpg|jepg|bmp|gif|png)$/.test(val)){
            }else{
                alert("只能上传jpg,bmp,gif,png格式的图片");
                categoryAd[x].select();
                return false;
            }
        }
    }
    return true;
}
///验证品牌表单
function checkBrandForm()
{
    var brandName=document.getElementById("txtBrandName");
    if(brandName.value=="")
    {
        alert("请输入品牌名称！");
        brandName.focus();
        return false;
    }
    var brandLogo=document.getElementById("fileBrandLogo");
    
    if(location.search=="?ot=ad")
    {
        if(brandLogo.value=="")
        {
            alert("请选择品牌LOGO！");
            brandLogo.focus();
            return false;
        }
        if(brandLogo.value != "")
        {
            //检测类型
            var val = brandLogo.value.toLowerCase();
            if(/^.*?\.(gif|png)$/.test(val)){
            }else{
                alert("LOGO只能上传gif, png格式的图片");
                brandLogo.select();
                return false;
            }
        }
    }
    else
    {
        if(brandLogo.value != "")
        {
            //检测类型
            var val = brandLogo.value.toLowerCase();
            if(/^.*?\.(gif|png)$/.test(val)){
            }else{
                alert("LOGO只能上传gif, png格式的图片");
                brandLogo.select();
                return false;
            }
        }
    }
    var regUrl=/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]':+!]*([^<>\"\"])*$/;
    var brandUrl=document.getElementById("txtBrandUrl");
    if(brandUrl.value=="")
    {
        alert("请输入品牌网址！");
        brandUrl.focus();
        return false;
    }
    else
    {
        if(brandUrl.value.match(regUrl)==null)
        {
            alert("请输入正确的品牌网址！");
            brandUrl.select();
            return false;
        }
    }
    var sortOrder=document.getElementById("txtSortOrder");
    if(sortOrder.value=="")
    {
        alert("请输入排序！");
        sortOrder.focus();
        return false;
    }
    var brandDescription=document.getElementById("txtaBrandDescription");
    if(brandDescription.value.length>500)
    {
        alert("品牌描述不能超过500个字符！");
        sortOrder.select();
        return false;
    }
    return true;
}
///验证角色表单
function checkAdminGroupForm()
{
    var groupName=document.getElementById("txtGroupName");
    if(groupName.value=="")
    {
        alert("请输入角色名称！");
        groupName.focus();
        return false;
    }
    var remark=document.getElementById("txtaRemark");
    if(remark.value.length>200)
    {
        alert("描述不能超过200个字符！");
        remark.select();
        return false;
    }
    return true;
}
///验证管理员表单
function checkAdminForm()
{
    var userName=document.getElementById("txtUserName");
    if(userName.value=="")
    {
        alert("请输入用户名！");
        userName.focus();
        return false;
    }
    var userPwd=document.getElementById("txtUserPwd");
    var againUserPwd=document.getElementById("txtAgainUserPwd");
    if(location.search=="?ot=ad")
    {
        if(userPwd.value=="")
        {
            alert("请输入密码！");
            userPwd.focus();
            return false;
        }
        if(againUserPwd.value=="")
        {
            alert("请输入确认密码！");
            againUserPwd.focus();
            return false;
        }
        if(againUserPwd.value!=userPwd.value)
        {
            alert("确认密码不一致！");
            againUserPwd.select();
            return false;
        }
    }
    else
    {
        if(userPwd.value!="")
        {
            if(againUserPwd.value=="")
            {
                alert("请输入确认密码！");
                againUserPwd.focus();
                return false;
            }
            if(againUserPwd.value!=userPwd.value)
            {
                alert("确认密码不一致！");
                againUserPwd.select();
                return false;
            }
        }
    }
    var regu =/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    var email=document.getElementById("txtEmail");
    if(email.value=="")
    {
        alert("请输入邮箱！");
        email.focus();
        return false;
    }
    else if(email.value.match(regu)==null)
    {
        alert("请输入正确的邮箱！");
        email.select();
        return false;
    }
    var adminGroup=document.getElementById("selectAdminGroup");
    if(adminGroup.options[adminGroup.selectedIndex].value=="0")
    {
        alert("请选择用户角色！");
        adminGroup.focus();
        return false;
    }
    return true;
}
function setFreightTemplate(){
    var ft=$("#selectFreightTemplate").val();
    if(parseInt(ft)==0)
        $("#spFreightTemplate").html("");
    else{
        $("#spFreightTemplate").html("<a href=\"javascript:void(0);\" onclick=\"alert('体验版此功能未开通！');\">设置运费方式</a>");
    }    
}